    
    {mfdeclre.i}
    {gplabel.i}
    
    define input parameter pWorkOrderId as character no-undo.
    define input parameter pPart        as character no-undo.
    define input parameter pOp          as integer   no-undo.
    
    for first wo_mstr no-lock where wo_lot = pWorkOrderID :
    end.
	
    for first wod_det exclusive-lock where wod_lot = pWorkOrderID and wod_part = pPart and wod_op = pOp :
    end.

    if not available wod_det then return.

    find in_mstr where in_part = wod_part and in_site = wod_site exclusive-lock no-error.

    if available in_mstr then do:
          in_qty_req = in_qty_req - wod_qty_req.
    end.

    /* Work order components */
    {mfmrwdel.i "wod_det" wod_part wod_nbr wod_lot """"}

    {mfmrw.i "wod_det" wod_part wod_nbr wod_lot string(wod_op)
           ? wod_iss_date 0 "DEMAND" WORK_ORDER_COMPONENT wod_site}

    for each lad_det where lad_dataset = "wod_det" and lad_nbr = wod_lot and lad_line = string(wod_op) 
        and lad_part = wod_part exclusive-lock:
        
        find ld_det where ld_site = lad_site and ld_loc = lad_loc and ld_lot = lad_lot 
            and ld_part = lad_part and ld_ref = lad_ref exclusive-lock no-error.

        if available ld_det then
            ld_qty_all = ld_qty_all - (lad_qty_all + lad_qty_pick).

        delete lad_det.

    end.

    find qad_wkfl exclusive-lock where qad_key1 = "MFWORLA"
        and qad_key2 = wod_lot + wod_part + string(wod_op) no-error.

    if available qad_wkfl then delete qad_wkfl.

    delete wod_det.
